package com.xuelang.pipeline.client.pipeline.enums;

import lombok.Getter;

/**
 * <p>星期枚举</p>
 *
 * @author : yixin.lys
 * @date : 2024-06-12 16:46
 **/
@Getter
public enum WeekDayEnum {

    SUN(0, "Sunday"),
    MON(1, "Monday"),
    TUE(2, "Tuesday"),
    WED(3, "Wednesday"),
    THU(4, "Thursday"),
    FRI(5, "Friday"),
    SAT(6, "Saturday");

    private final int value;
    private final String fullName;

    WeekDayEnum(int value, String fullName) {
        this.value = value;
        this.fullName = fullName;
    }

    public static WeekDayEnum fromValue(int value) {
        for (WeekDayEnum day : WeekDayEnum.values()) {
            if (day.value == value) {
                return day;
            }
        }
        throw new IllegalArgumentException("Invalid value: " + value);
    }

    public static WeekDayEnum fromShortName(String shortName) {
        for (WeekDayEnum day : WeekDayEnum.values()) {
            if (day.name().equalsIgnoreCase(shortName)) {
                return day;
            }
        }
        throw new IllegalArgumentException("Invalid short name: " + shortName);
    }

    @Override
    public String toString() {
        return this.name() + "(" + this.value + " - " + this.fullName + ")";
    }

}
